<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            html,body {
                box-sizing: border-box;
                width: 100%;
                /*height: 100%;*/
                display: flex;
                flex-direction: column;
            }
            #header {
                height: 40px;
                width: 100%;
                background-color: black;
                display: flex;
                color: white;
            }
            #title {
                margin-top: 0px;
                line-height: 40px;
            }
            #header_left {
                margin: 0px;
                margin-left: 15px;
                float: left;
            }
            #header_right {
                float: right;
                line-height: 40px;
            }
            img {
                height: 30px;
                margin-top: 5px;
                margin-right: 10px;
                float: left;
            }
            a {
                text-decoration: none;
                color: black;
            }
            #footer {
                height: 100px;
                width: 100%;
                background-color: #e3e3e3;
            }
            .footer p {
                margin-top: 30px;
                margin-left: 15px;
            }
        </style>
    </head>
    <body>
        <div id="header">
            <div style="width:95%;">
                <h1 id="header_left"><a href="show_bbs.php" style="color:white">mybbs</a> <input type="text" placeholder="站内搜索"/></h1>
                <span id="header_right">
                    <?php
                    function wordTime($time) {
                        $time = (int) substr($time, 0, 10);
                        $int = time() - $time;
                        $str = '';
                        if ($int <= 2) {
                            $str = sprintf('刚刚', $int);
                        } elseif ($int < 60) {
                            $str = sprintf('%d秒', $int);
                        } elseif ($int < 3600) {
                            $str = sprintf('%d分钟', floor($int / 60));
                        } elseif ($int < 86400) {
                            $str = sprintf('%d小时', floor($int / 3600));
                        } elseif ($int < 2592000) {
                            $str = sprintf('%d天', floor($int / 86400));
                        } else {
                            $str = date('Y-m-d H:i:s', $time);
                        }
                        return $str;
                    }

                    try {
                        $dsn = 'mysql:host=localhost;dbname=yunbbs;charset=utf8';
                        $pdo = new PDO($dsn, 'root', '123456', array(
                            PDO:: ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
                        ));
                    } catch (PDOException $ex) {
                        echo '链接数据库失败';
                    }
                    $yunbbs_categories = $pdo->query("select * from yunbbs_categories");
                    $name = isset($_COOKIE['name']) ? $_COOKIE['name'] : '';
                    if ($name) {
                        ?>
                        <img src=
                        <?php
                        $user_info = $pdo->query("select avatar from yunbbs_users where name='$name'");
                        foreach ($user_info as $key => $value) {
                            echo $value['avatar'];
                        }
                        ?>>
                        <a href="souchang.php" style="color:white;">☆</a>
                        <a href="per_info.php?name=$name" id="per_info" style="color:white"><?php echo $name; ?></a>
                        <?php
                        echo '<a href="set_bbs.php?name=$name" style="color: white;"> 设置</a>' . '<a href="exit.php" style="color: white;"> 退出</a>';
                    } else {
                        echo '<a href = "login.php" style="color: white;">登录</a> <a href = "reginst.php" style="color: white;">注册</a>';
                    }
                    ?>
                </span>
            </div>
        </div>
        <div id = "body">   
